var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        showAddress: !1,
        showAddrss: !1,
        activityInfo: {},
        activity_id: 0,
        reward_data_id: 0,
        list: [],
        page: 1,
        isLoadMore: !0,
        total_page: 0
    },
    onLoad: function(t) {
        this.getData();
    },
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.luck-draw.frontend.index.recommendList");
        a._postNetWork({
            url: e,
            data: {},
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    isLoadMore: !0,
                    total_page: e.data.last_page,
                    list: e.data.data
                }) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        t.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        urlStr = a.getNetAddresss("plugin.luck-draw.frontend.index.recommendList"), a._postNetWork({
            url: {},
            showToastIn: !1,
            data: json,
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    isLoadMore: !0,
                    list: t.data.list.concat(e.data.data)
                }) : t.setData({
                    page: t.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        }));
    },
    addActivity: function() {
        var t = this, e = a.getNetAddresss("plugin.luck-draw.frontend.team.getActivity");
        a._postNetWork({
            url: e,
            data: {
                activity_id: t.data.activity_id
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    activityInfo: e.data,
                    showAddrss: !0
                }) : wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    getAddress: function() {
        this.setData({
            addressData: [],
            showAddress: !0
        });
    },
    confirmSelectAddress: function(a) {
        var e;
        this.setData((t(e = {}, "activityInfo.address", a.detail), t(e, "showAddress", !1), 
        e));
    },
    joinActivity: function() {
        var t = this, e = {
            reward_data_id: t.data.reward_data_id,
            address: JSON.stringify(this.data.activityInfo.address)
        };
        if (2 == this.data.activityInfo.type && 1 == this.data.activityInfo.need_address) {
            if ("" == this.data.tel) return void wx.showToast({
                title: "请填写手机号",
                duration: 1e3,
                icon: "none"
            });
            e.address = JSON.stringify({
                mobile: this.data.tel
            });
        } else if (0 == Object.keys(this.data.activityInfo.address).length) return void wx.showToast({
            title: "请选择收货地址",
            duration: 1e3,
            icon: "none"
        });
        var i = a.getNetAddresss("plugin.luck-draw.frontend.team.rewardJoinActivity");
        a._postNetWork({
            url: i,
            data: e,
            success: function(a) {
                var e = a.data;
                wx.showToast({
                    title: e.msg,
                    duration: 1e3,
                    icon: "none"
                }), 1 == e.result && (t.getData(), t.setData({
                    showAddrss: !1
                }));
            },
            fail: function(t) {
                console.log(t.msg);
            }
        });
    },
    cloneAdress: function() {
        this.setData({
            showAddrss: !1
        });
    },
    confirmBtn: function(t) {
        var a = t.currentTarget.dataset.index, e = t.currentTarget.dataset.item;
        this.data.activity_id = e.activity_id, this.data.reward_data_id = e.reward_data_id, 
        0 == a ? this.addActivity() : e.order_id && wx.navigateTo({
            url: "/packageA/member/orderdetail/orderdetail?order_id=" + e.order_id + "&orderType=luck-draw"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {}
});